interface IdCardGeneratorRequest {
  // 请求配置
  url: 'https://openapi.lddgo.net/base/gtool/api/v1/GeneratorIdentityWithFullComplex',
  method: 'POST',
  headers: {
    'Content-Type': 'application/json;charset=UTF-8',
    'Accept': 'application/json',
    'Origin': 'https://www.lddgo.net',
  }
}
interface IdCardGeneratorParams {
  count: number          // 生成数量
  birthday?: string      // 出生日期，可选
  areaID?: string       // 地区ID，可选
  male?: boolean        // 性别，可选
  includeName: boolean  // 是否包含姓名
  minAge?: number       // 最小年龄，可选
  maxAge?: number       // 最大年龄，可选
}

const generateIdCard = async (params: IdCardGeneratorParams = {
  count: 1,
  includeName: false
}) => {
  try {
    const response = await uni.request({
      url: 'https://openapi.lddgo.net/base/gtool/api/v1/GeneratorIdentityWithFullComplex',
      method: 'POST',
      header: {
        'Content-Type': 'application/json;charset=UTF-8'
      },
      data: params
    })
    return response.data
  } catch (error) {
    console.error('生成身份证号失败', error)
    throw error
  }
}

export { generateIdCard, type IdCardGeneratorParams }